package com.SFEIR.GWT.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class FormationGWT implements EntryPoint {
	public void onModuleLoad() {
		final RootPanel rootPanel = RootPanel.get();
		final TextBox tbSaisie = new TextBox();
		Button btnValider = new Button("Valider");
		final Label lblBouge	  = new Label("azerty");
		
		rootPanel.add(tbSaisie, 0, 0);
		rootPanel.add(btnValider,tbSaisie.getOffsetWidth(), 0);
		rootPanel.add(lblBouge, 300, 100);
		
		Timer t = new Timer() {
			@Override
			public void run() {
				
				int xLabel = Random.nextInt(527);
				int yLabel = Random.nextInt(527);
				
				rootPanel.add(lblBouge, xLabel, yLabel);
			}
		};
		t.scheduleRepeating(521);
		
		btnValider.addClickHandler(new ClickHandler(){
			public void onClick(ClickEvent event) {
				String Textsaisi = tbSaisie.getText();
				
				if( Textsaisi.equals(lblBouge.getText())){
					lblBouge.setVisible(false);
				}
			}
		});
	}
}
